﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataVisit.Factory;

namespace DataVisit.Handler.View
{
    public class ProductReportView:AbstractView
    {
        //获取产量收入数量
        public void GetData()
        {
            var year = JsonRequest.GetParam<string>("year");
            var month = JsonRequest.GetParam<string>("month");
            JsonResponse.ResponseObject = DaoFactory.ProductReportDao.GetData(year + "-" + month + "-01");
        }

        //获取材料统计数量
        public void GetMaterialsData()
        {
            var year = JsonRequest.GetParam<string>("year");
            var month = JsonRequest.GetParam<string>("month");
            JsonResponse.ResponseObject = DaoFactory.ProductReportDao.GetMaterialsData(year + "-" + month + "-01");
        }

        //租赁资金
        public void GetRentalPrice()
        {
            var year = JsonRequest.GetParam<string>("year");
            var month = JsonRequest.GetParam<string>("month");
            JsonResponse.ResponseObject = DaoFactory.ProductReportDao.GetRentalPrice(year + "-" + month + "-01");
        }

        //租赁数量
        public void GetRentalCount()
        {
            var year = JsonRequest.GetParam<string>("year");
            var month = JsonRequest.GetParam<string>("month");
            JsonResponse.ResponseObject = DaoFactory.ProductReportDao.GetRentalCount(year + "-" + month + "-01");
        }

        //设备基本信息和状态
        public void GetEquipmentInfo()
        {
            var year = JsonRequest.GetParam<string>("year");
            var t = JsonRequest.GetParam<string>("t");
            var con = JsonRequest.GetParam<string>("con");
            var index = Convert.ToInt32(JsonRequest.GetParam<string>("currentpage"));
            var size = Convert.ToInt32(JsonRequest.GetParam<string>("pagesize"));
            JsonResponse.ResponseObject = DaoFactory.ProductReportDao.GetEquipmentInfoData(year + "-01-01",t,con,size,index);
        }

        //设备基本信息和状态总和
        public void GetEquipmentInfoCount()
        {
            var year = JsonRequest.GetParam<string>("year");
            var t = JsonRequest.GetParam<string>("t");
            var con = JsonRequest.GetParam<string>("con");
            var pagesize = Convert.ToInt32(JsonRequest.GetParam<string>("pagesize"));
            int k= DaoFactory.ProductReportDao.EquipmentCount(year + "-01-01", t, con);
            JsonResponse.ResponseObject = k % pagesize != 0 ? k / pagesize + 1 : k / pagesize;
        }
    }
}
